package _2022.contest.biweekly.biweekly_contest_75;

/**
 * @author： YHSimon
 * @date： 2022-04-02 23:34
 */
public class Solution4 {
    public long sumScores(String s) {
        long res=0;
        int len=s.length();
        for(int i=len-1;i>0;i--){
            int cur=i;
            int j=0;
            while(cur<len&&s.charAt(cur)==s.charAt(j)){
                cur++;
                j++;
                res++;
            }
        }
        return res+len;
    }

    public long sumScores2(String s) {
        long res=0;
        int len=s.length();
        res+=len;
        for(int i=1;i<len;i++){
            int cur=i;
            int j=0;
            while(cur<len&&s.charAt(cur)==s.charAt(j)){
                res++;
                cur++;
                j++;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Solution4 s = new Solution4();
        System.out.println(s.sumScores2("azbazbzaz"));
    }
}
